From: Keir Fraser Date: Wed, 26 May 2010 07:08:46 +0000 (+0100) Subject: x86 EPT: Only flush EPT TLB if the previous entry was valid X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12088 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=490926221829ef47759528971de69baaa16131fc;p=xen.git x86 EPT: Only flush EPT TLB if the previous entry was valid Original patch from George Dunlap Signed-off-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/hap/p2m-ept.c b/xen/arch/x86/mm/hap/p2m-ept.c index dbdbd7aaee..798f4ccedd 100644 --- a/xen/arch/x86/mm/hap/p2m-ept.c +++ b/xen/arch/x86/mm/hap/p2m-ept.c @@ -242,6 +242,7 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, int direct_mmio = (p2mt == p2m_mmio_direct); uint8_t ipat = 0; int need_modify_vtd_table = 1; + int needs_sync = 1; struct p2m_domain *p2m = p2m_get_hostp2m(d); if ( order != 0 ) @@ -276,6 +277,11 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, if ( i == walk_level ) { /* We reached the level we're looking for */ + + /* No need to flush if the old entry wasn't valid */ + if ( !(ept_entry->epte & 7) ) + needs_sync = 0; + if ( mfn_valid(mfn_x(mfn)) || direct_mmio || p2m_is_paged(p2mt) || (p2mt == p2m_ram_paging_in_start) ) { @@ -336,7 +342,8 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, out: unmap_domain_page(table); - ept_sync_domain(d); + if ( needs_sync ) + ept_sync_domain(d); /* Now the p2m table is not shared with vt-d page table */ if ( rv && iommu_enabled && need_iommu(d) && need_modify_vtd_table )